from datetime import datetime
from typing import List

from pydantic import Field

from server.schemas.BaseSchema import BaseSchema


class AddRole(BaseSchema):
    """
    添加权限
    """
    name: str = Field(..., min_length=3, max_length=100)
    code: str = Field(None, min_length=3, max_length=100)
    description: str = Field(None, min_length=3, max_length=500)
    is_active: bool = True
    is_deleted: bool = False


class UpdateRole(AddRole):
    """
    修改角色信息
    """
    id: str = Field(..., min_length=18)


class DeleteRole(BaseSchema):
    """
    删除角色信息
    """
    id: str = Field(..., min_length=18)


class RoleResponse(BaseSchema):
    """
    角色响应模型
    """
    id: str
    name: str
    code: str
    description: str
    is_active: bool = True
    created_at: datetime
    updated_at: datetime


class RolesListResponse(BaseSchema):
    """
    角色列表响应模型
    """
    data: List[RoleResponse]


class RoleAlreadyExists(BaseSchema):
    """
    角色已存在响应模型
    """
    code: int = 1400
    msg: str = "角色已存在"

